<%@ page language="java" import="java.util.*" pageEncoding="utf-8"%>
<%@ taglib uri="http://java.sun.com/jsp/jstl/core" prefix="c" %>
<%@ taglib prefix="shiyue" uri="http://www.shiyue.com" %>
<%--
 /**
  功能名称:学生列表
  
  创建人:
*/
--%>
<%
String path = request.getContextPath(); 
%>
<html>
  <head>
    <title>学生列表</title>
	<link href="<%=path%>/css/index_css.css" rel="stylesheet" type="text/css" />
	<link rel="stylesheet" type="text/css" href="<%=path %>/css/paging.css">
	<script src="<%=path%>/js/resizeIframe.js" type="text/javascript"></script>
	<script src="<%=path %>/dwr/engine.js"></script>
	<script src="<%=path %>/dwr/util.js"></script>
	<script src="<%=path %>/dwr/interface/shiyueDwr.js"></script>
	<script src="<%=path%>/js/syAjax.js" type="text/javascript"></script>
	<script language="javascript" src="<%=path %>/js/paging.js"></script>
	<script type="text/JavaScript">
	var pageInfo = ${shiyue:toJSONWithExclude(pageInfo, "class,pageData")};
	window.onload   =   function(){
		var objURL="<%=path%>/findAllUserByTypeAndStatusUserAction.action?user.userType=1&user.status=1";
		if('${requestScope.pageURL}'!=null && '${requestScope.pageURL}'!=""){
				objURL='${requestScope.pageURL}';
		}
		paging(objURL,pageInfo);
		shiyueDwr.findAllGradeByYear('${applicationScope.currentYear}',1,findGradeCallBack);
    	shiyueDwr.findCodeByCodeMaintenanceTypeId("sex",getsexCallBack);
        resizeIframe();
        document.getElementsByName("img").src+="&t="+new Date();	
	}
	
	function checkAll(){
		var chk1 = document.getElementById('chk1');
		var arr=document.getElementsByName('checkbox2');
		for(var i=0;i<arr.length;i++){
			arr[i].checked=chk1.checked;
		}
		
	}
	
	function doDelete(){
		
			var userIds="";
			var checkedCount=0;
			var arr=document.getElementsByName('checkbox2');
			for(var i=0;i<arr.length;i++){
				if(arr[i].checked){
					checkedCount++;
					userIds+=arr[i].value+",";
				}
			}
			if(checkedCount==0){
				alert('请选择要删除的信息！');
			}else{
				if(confirm('确定要删除吗？')){
					document.getElementById('userIds').value=userIds;
					var pageurl="";
					if(document.getElementById('class').value==''){						
					   	pageurl="findAllUserByTypeAndStatusUserAction.action?user.userType=1&user.status=1";
					   
					}else{
					   pageurl="selectUserByClassIdAndYearAndRoleorganizationAction.action?grade.gradeId="+document.getElementById('grade').value+"&user.userType=1&cla.classId="+document.getElementById('class').value+"&years=${applicationScope.currentYear}&role.roleId=member&ispageURL=true";
					}
					
					document.getElementById('pageURL').value=pageurl;
					document.getElementById('delClassId').value=document.getElementById('class').value;
					document.getElementById('delGradeId').value=document.getElementById('grade').value;
					document.forms[0].submit();
				}
			}
		
		
		
	}
	
	function toTeaList(){
		window.location.href='findAllUserByTypeAndStatusUserAction.action?user.userType=2&user.status=1';
	}

	
	function findGradeCallBack(orgMap) {
		 DWRUtil.removeAllOptions("grade");	
	     DWRUtil.addOptions("grade", orgMap);
	      if('${GRADEID}'!='')
	      {
	        document.getElementById("grade").value="${GRADEID}";
	      }
	  
	      shiyueDwr.findAllClassByYearAndStatusAndGradeId('${applicationScope.currentYear}',1,'${GRADEID}',findClassByGradeIdCallBack);
	      
    }
    
    function findClassByGradeIdCallBack(orgMap){
    	DWRUtil.removeAllOptions("class");
    	DWRUtil.addOptions("class", orgMap);
    	if('${CLASSID}'!='')
	      {
	        document.getElementById("class").value="${CLASSID}";
	        
	      }
    	
    	
    }
      

    
    	//性别
    function getsexCallBack(map)
    {
      <c:if test="${requestScope.UserList!=null}">
      <c:forEach items="${UserList}" var="p">
      	if(map["${p.sex}"]!=undefined){
      		document.getElementById("${p.userId}Sex").innerHTML=map["${p.sex}"];
      	}
      </c:forEach>
      </c:if>
    }
    

    

     function doAddStudent(){
  
    	
     		var returnStr=window.showModalDialog("<%=path%>/toSaveUserAction.action?user.userType=1&classId="+document.getElementById('class').value,"","dialogHeight:430px;dialogWidth:700px;help=0;scroll=1;"); 	
    		if(returnStr=="true"){
    			if(document.getElementById('class')!=null && document.getElementById('class').value!=""){
		    		window.location.href="selectUserByClassIdAndYearAndRoleorganizationAction.action?grade.gradeId="+document.getElementById('grade').value+"&user.userType=1&cla.classId="+document.getElementById('class').value+"&years=${applicationScope.currentYear}&role.roleId=member&ispageURL=true";
		    	}else{     	
    				window.location.href="findAllUserByTypeAndStatusUserAction.action?user.userType=1&user.status=1";
    			}
    		}		
    }
    
  
    

    
    
    
    
    //更新学生信息
    function doUpdateStudent(userId){
    		var returnStr=window.showModalDialog("<%=path%>/toUpdateUserAction.action?user.userId="+userId+"&t="+new Date(),"","dialogHeight:367px;dialogWidth:658px;help=0;scroll=1;");   	
    		if(returnStr=="true"){   	
    			window.location.href="findAllUserByTypeAndStatusUserAction.action?user.userType=1&user.status=1";
    		}
    	
    }
    
  
     
     function changeGrade(gradeId){
   
     		if(gradeId==""){
     			window.location.href='findAllUserByTypeAndStatusUserAction.action?user.userType=1&user.status=1';
     		}else{
     			window.location.href="selectUserByGradeIdAndYearAndRoleorganizationAction.action?user.userType=1&grade.gradeId="+gradeId+"&years=${applicationScope.currentYear}&role.roleId=member&ispageURL=true";
     		}
     	
     }
     
     function changeClass(classId){
   
     		var gradeId = document.getElementById('grade').value;
     		if(classId==""){
     			window.location.href='findAllUserByTypeAndStatusUserAction.action?user.userType=1&user.status=1';
     		}else{
     			window.location.href="selectUserByClassIdAndYearAndRoleorganizationAction.action?grade.gradeId="+gradeId+"&user.userType=1&cla.classId="+classId+"&years=${applicationScope.currentYear}&role.roleId=member&ispageURL=true";
     		}
     	
     }
     
     function doExportExcel(){
     	window.open("<%=path%>/baseSet/user/batchGetTeacher.jsp?userType=1","1","height=250px,width=700px,scrollbars=1;");
     	
     }
     
      //批量导入
     function doImportExcel(){
     		document.getElementById('excelbackURL').value="findAllUserByTypeAndStatusUserAction.action?user.userType=1&user.status=1";
     		document.excelForm.submit();
     }
     

    function searchUser(){
     	var gradeId=document.getElementById("grade").value;
     	var classId=document.getElementById("class").value;
     	var UserName=document.getElementById("username").value;
		UserName=encodeURI(UserName);
		if(classId!=""){
			window.location.href="selectUserByClassIdAndYearAndRoleAndNameorganizationAction.action?grade.gradeId="+gradeId+"&user.userType=1&cla.classId="+classId+"&years=${applicationScope.currentYear}&role.roleId=member&ispageURL=true&user.name="+UserName;
		}else if(gradeId!=""){
			window.location.href="selectUserByGradeIdAndYearAndRoleAndNameorganizationAction.action?user.userType=1&grade.gradeId="+gradeId+"&years=${applicationScope.currentYear}&role.roleId=member&ispageURL=true&user.name="+UserName;
		}else{
			window.location.href="findUsersByTypeAndUnitAndNameAndStatusUserAction.action?user.userType=1&user.status=1&user.name="+UserName;
		}
     }     
        function doSomeUpdate(){
     	var userIds="";
			var checkedCount=0;
			var arr=document.getElementsByName('checkbox2');
			for(var i=0;i<arr.length;i++){
				if(arr[i].checked){
					checkedCount++;
					userIds+=arr[i].value+",";
				}
			}
			if(checkedCount==0){
				alert('请选择要批量修改的用户！');
			}else{
				window.open("<%=path%>/tobatchUpdateUserUserAction.action?userIds="+userIds);
				
			}
     }
     
	</script>
  </head>
  
  <body>
   <form action="<%=path %>/deleteUserAction.action" method="post">
  <input id="userIds" type="hidden" name="userIds" value="" />
  <!-- 耳日 修改设置userType值为1 -->
  <input type="hidden" name="user.userType" value="${user.userType }" />
  <input type="hidden" name="user.status" value="1" />
  <input id="pageURL" type="hidden" name="pageURL" value="" />
  <input id="delGradeId" type="hidden" name="delGradeId" value="" />
  <input id="delClassId" type="hidden" name="delClassId" value="" />
  <input type="hidden" name="isStuOrTea" value="stu" />
  
	
    <table width="100%" border="0" cellspacing="0" cellpadding="0">
  <tr>
    <td colspan="2" align="left" class="f_5">用户管理</td>
  </tr>
  <tr>
    <td height="1" colspan="2" bgcolor="#9DD12E"></td>
  </tr>
  <tr>
    <td colspan="2" align="left" valign="top">&nbsp;</td>
  </tr>
  <tr>
    <td colspan="2" align="left"><table width="100%" border="0" cellspacing="0" cellpadding="0">
      <tr>
        <td align="left" valign="bottom" background="<%=path %>/images/sywesp_24.gif"><table width="100%" border="0" cellspacing="0" cellpadding="0">
          <tr>
            
            <td width="90" align="left">
            <table width="90" border="0" cellspacing="0" cellpadding="0">
              <tr>
                <td width="1" align="left" valign="bottom" bgcolor="#CBCBCB"></td>
                <td align="center" background="<%=path %>/images/sywesp_18.gif" style="cursor:pointer;" onclick="toTeaList();" class="f_6">
                教师用户
                
                </td>
                <td width="1" height="31" align="right" valign="bottom" bgcolor="#CBCBCB"></td>
              </tr>
            </table></td>
            <td width="5" align="left">&nbsp;</td>
            <td width="90" align="left"><table width="90" border="0" cellspacing="0" cellpadding="0">
              <tr>
                <td width="1" align="left" valign="bottom" bgcolor="#CBCBCB"></td>
                <td align="center" background="<%=path %>/images/sywesp_25.gif" class="f_9">学生用户</td>
                <td width="1" height="31" align="right" valign="bottom" bgcolor="#CBCBCB"></td>
              </tr>
            </table></td>
            <td align="left">&nbsp;</td>
            </tr>
        </table></td>
      </tr>
      <tr>
        <td align="left" valign="top" class="tb_8 border_2"><table width="100%" border="0" cellspacing="0" cellpadding="0">
            <tr>
              <td height="25" align="right" bgcolor="#FFFFFF" class="f_6">
              	 年级：
                <select id="grade" onchange="changeGrade(this.value);">
                 <option value="">---请选择---</option>
                </select>
                &nbsp;
                   班级：
                <select id="class" onchange="changeClass(this.value);">
                 <option value="">---请选择---</option>
                </select>

              <span style="margin-left:20px;white-space:nowrap"><label for="username">帐号/姓名</label><input id="username" value="${requestScope.user.name }" name="name" type="text" style="width:100px" maxlength="16"/>
              <button type="button" onclick="searchUser();" style="margin-left:4px;">搜索</button>
              </span>
                </td>
              </tr>
            <tr>
              <td height="30" align="right" valign="bottom" background="<%=path %>/images/sywesp_26.gif"><a href="javascript:doAddStudent();"  ><img src="<%=path %>/images/icon_newuser.gif" name="Image11" width="85" height="24" border="0" id="Image11" /></a>&nbsp;<a href="javascript:doImportExcel();"  ><img src="<%=path %>/images/icon_dr.gif" name="Image10" width="99" height="24" border="0" id="Image10" /></a>&nbsp;<a href="<%=path %>/baseSet/user/batchAddImage.jsp?paramUserType=1"  ><img src="<%=path %>/images/icon_dr2.gif" name="Image10" width="99" height="24" border="0" id="Image10" /></a>&nbsp;<a href="javascript:doExportExcel();" ><img src="<%=path %>/images/icon_dc.gif" name="Image9" width="99" height="24" border="0" id="Image9" /></a>&nbsp;<a href="javascript:doDelete();"  ><img src="<%=path %>/images/icon_delete.gif" name="Image8" width="57" height="24" border="0" id="Image8" /></a>&nbsp;&nbsp;<a href='javascript:doSomeUpdate();'  ><img src="<%=path %>/images/icon_sywesp_0125_1.gif" name="Image125" width="75" height="24" border="0" id="Image125" /></a></td>
            </tr>
            <tr>
              <td height="30" align="left" valign="top"><table width="100%" border="0" cellspacing="0" cellpadding="0">
                <tr>
                  <td align="left" valign="top"><table width="100%" border="0" cellspacing="0" cellpadding="0">
                      <tr>
                        <td align="left" valign="top"><table width="100%" border="0" cellspacing="0" cellpadding="0">
                            <tr>
                              <td width="2" height="24" align="left" background="<%=path %>/images/sywesp_21.gif"><img src="<%=path %>/images/sywesp_20.gif" width="2" height="24" /></td>
                              <td align="left" background="<%=path %>/images/sywesp_21.gif"><table width="100%" border="0" cellspacing="0" cellpadding="0">
                                  <tr>
                                    <td width="1%">&nbsp;</td>
                                    <td width="8%" align="left" class="f_8"><img src="<%=path %>/images/sywesp_23.gif" width="8" height="22" align="absmiddle" />头像</td>
                                    <td width="31%" align="left" class="f_8"><img src="<%=path %>/images/sywesp_23.gif" width="8" height="22" align="absmiddle" />编号</td>
                                    <td width="31%" align="left" class="f_8"><img src="<%=path %>/images/sywesp_23.gif" width="8" height="22" align="absmiddle" />帐号：姓名</td>
                                    <td width="7%" align="left" class="f_8"><img src="<%=path %>/images/sywesp_23.gif" width="8" height="22" align="absmiddle" />性别</td>
                                    <td width="10%" align="left" class="f_8"><img src="<%=path %>/images/sywesp_23.gif" width="8" height="22" align="absmiddle" />手机号码</td>
                                    <td width="5%" align="left" class="f_8" style= "display:none " ><img src="<%=path %>/images/sywesp_23.gif" width="8" height="22" align="absmiddle" />权限</td>
                                    <td width="5%" align="left" class="f_8"><img src="<%=path %>/images/sywesp_23.gif" width="8" height="22" align="absmiddle" />操作</td>
                                    <td width="3%" align="left" class="f_8"><input id="chk1" type="checkbox" onclick="checkAll();" name="checkbox" value="checkbox" /></td>
                                  </tr>
                              </table></td>
                              <td width="4" align="right" background="<%=path %>/images/sywesp_21.gif"><img src="<%=path %>/images/sywesp_22.gif" width="4" height="24" /></td>
                            </tr>
                        </table></td>
                      </tr>
                      <tr>
                        <td align="left" valign="top">
                        <c:if test="${requestScope.UserList!=null}">
                        <c:forEach items="${UserList}" var="p">
                        <table width="100%" border="0" cellspacing="0" cellpadding="0">
                            <tr>
                              <td height="25" align="left" valign="top" class="tb_7"><table width="100%" border="0" cellspacing="1" cellpadding="0">
                                  <tr>
                                    <td width="1%" align="right" valign="bottom">&nbsp;</td>
                                    <td width="8%" height="35" align="center">
	                                    <c:choose>
						                <c:when test="${empty p.img }"><font color="#CCCCCC">无头像</font></c:when>
						                <c:otherwise>						   
						                <img src="${applicationScope.currentEnclosureServer.outUrl }/enclosure/${p.img}" name="img" width="26" height="35" align="middle" />
						                
						                </c:otherwise>
						                </c:choose>
                                    </td>
                                    <td width="31%" height="25" align="left" valign="bottom">${p.userId }</td>
                                    <td width="31%" height="25" align="left" valign="bottom">${p.account }：${p.name }</td>
                                    <td width="6%" align="left" valign="bottom">
                                    <span id="${p.userId }Sex"></span>
                                    </td>
                                    <td width="10%" valign="bottom">${p.mobileNumber1 }</td>
                                    <td width="5%" valign="bottom" style= "display:none " ><img src="<%=path %>/images/icon_19.gif" width="18" height="21" onclick="javascript:alert('正在开发中');" style="cursor:pointer; display:none " /></td>
                                    <td width="5%" valign="bottom"> &nbsp;&nbsp;<a href="javascript:doUpdateStudent('${p.userId}');"><img alt="修改用户信息" src="<%=path %>/images/icon_5.gif" width="15" height="16" border="0" /></a></td>
                                    <td width="3%" valign="bottom"><span class="f_8">
                                      <input type="checkbox" name="checkbox2" value="${p.userId }" />
                                    </span></td>
                                  </tr>
                                </table>
                                  </td>
                            </tr>
                        </table>
                        </c:forEach>
                        </c:if>
                        <c:if test="${requestScope.UserList==null}">
                        <table width="100%" border="0" cellspacing="0" cellpadding="0">
                            <tr>
                              <td height="25" align="center" valign="top" class="tb_7">
                              	暂无数据
                              </td>
                            </tr>
                        </table>                       
                        </c:if>
                          
                          </td>
                      </tr>
                  </table></td>
                </tr>
              </table></td>
            </tr>
            <tr><td align="center" valign="top"><shiyue:paging/></td></tr>
          </table>
          </td>
      </tr>
      <tr>
        <td>&nbsp;</td>
      </tr>
      
        <tr>
        <td>
        	  <table width="100%" border="0" cellspacing="0" cellpadding="0">
            <tr>
              <td align="left" valign="top" class="tb_9 border_3">
              <table width="100%" border="0" cellspacing="0" cellpadding="0">
                <tr>
                  <td align="left"><img src="<%=path %>/images/icon_14.gif" width="62" height="17" /></td>
                </tr>
                <tr>
                  <td height="30" align="left" valign="middle"><img src="<%=path %>/images/icon_5.gif" width="15" height="16" /> 表示修改用户信息&nbsp;&nbsp;</td>
                </tr>
                <tr>
                	<td>&nbsp; </td>
                </tr>
              </table>
              </td>
            </tr>
          </table>
        
        </td>                                
      </tr>
      
    </table></td>
  </tr>
</table>
</form>
<form name="excelForm" action="<%=path %>/tobatchAddStudentUserAction.action" method="post">
	<input type="hidden" id="excelbackURL" name="backURL" value="<%=path%>/findAllUserByTypeAndStatusUserAction.action?user.userType=1&user.status=1">	
</form>
  </body>
</html>
